home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 6 / MacMania 6.toast / / Multimedia & Desktop / sk8 / SK8InJava / Code / Collections / ChunkedTextVisitState.java < prev    next >
Encoding:
Java Source  |  1997-02-27  |  1.3 KB  |  49 lines  |  [TEXT/CWIE]

  1. /*  SK8 © 1997 Apple Computer, Inc.
  2.     This code is protected under the current SK8 License
  3.     See http://sk8.research.apple.com/ for more information
  4.     Apple Research Laboratories
  5. */
  6.  
  7.  
  8.  
  9.  
  10. public class chunkedtextvisitstate extends textvisitstate {
  11.  
  12.     public int                 mCurrentChunkIndex;
  13.     
  14.     //constructor
  15.     public chunkedtextvisitstate (chunkedtext inCTC, int inCharPosition)  {
  16.         mTC = inCTC;
  17.         
  18.         if (inCharPosition > inCTC.stringLength())
  19.             throw new IndexOutOfBoundsException("ChunkedText index " + inCharPosition + " out of bounds");
  20.             
  21.         mCurrentPosition = inCharPosition; // 1st Char of current chunk
  22.         if (inCharPosition == 0) {
  23.             mCurrentChunkIndex = 1;
  24.         } else {
  25.             int[] chunkBounds;
  26.             int charScan = 0;
  27.             int chunkCount;
  28.             for (chunkCount = 1; charScan <= inCharPosition; chunkCount++){
  29.                 chunkBounds = inCTC.nextChunk(charScan  + 1);
  30.                 charScan = chunkBounds[1];
  31.             }
  32.             mCurrentChunkIndex = chunkCount;
  33.         }
  34.     }
  35.     
  36.         
  37.     public chunkedtextvisitstate (chunkedtext inCTC, 
  38.                                 int inCharPosition, 
  39.                                 int inChunkIndex)  {
  40.         mTC = inCTC;
  41.         
  42.         if (inCharPosition > inCTC.stringLength())
  43.             throw new IndexOutOfBoundsException("ChunkedText index " + inCharPosition +" out of bounds");
  44.             
  45.         mCurrentPosition = inCharPosition; // 1st Char of current chunk
  46.         mCurrentChunkIndex = inChunkIndex;
  47.  
  48.     }
  49. }